package com.seele.tigerwallet.ui.views;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.TextView;

@SuppressLint("AppCompatCustomView")
public class AssetsTextView extends TextView {
    Typeface font;
    private LinearGradient mLinearGradient;
    private Paint mPaint;
    private int mViewWidth = 0;
    private Rect mTextBound = new Rect();

    public AssetsTextView(Context context) {
        super(context);
    }

    public AssetsTextView(Context context,
                            AttributeSet attrs) {
        super(context, attrs);
    }

    public AssetsTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        font= Typeface.createFromAsset(context.getAssets(), "fonts/CENTURY_GOTHIC_BOLD.TTF");

    }

    @Override
    protected void onLayout(boolean changed,
                            int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        if (changed) {
            LinearGradient mLinearGradient = new LinearGradient(0, 0, getWidth(), getHeight(),
                    new int[]{ 0xffcfb283, 0xffc5a472},
                    null, Shader.TileMode.REPEAT);
            setTypeface(font);//设置字
            setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
            getPaint().setShader(mLinearGradient);


        }
    }


    @Override
    protected void onDraw(Canvas canvas) {





        super.onDraw(canvas);
    }
}
